<?php
session_start();
//require('dbconnection.php');
//db_connect();


function addTimes($id,$start,$end){

  $query="INSERT INTO times(id,start,end) VALUES ($id,$start,$end)\n";
  writeToFile($query);
  /*
   $result = mysql_query();
   if (!$result)
   throw new Exception("There is no result")
  */
}
function addDistractors($id,$image,$text){
  // Number of distractors
  $query="INSERT INTO distractors(id,image,text) VALUES ($id,$image,$text)\n";
  writeToFile($query);
  
  //$result = mysql_query($query);
  //if (!$result)
  //  throw new Exception("There is no result")
}


function addMatchingTerm($id,$term){
  $query = "INSERT INTO matchingTerm(id,term) VALUES ($id,$term)\n";
  writeToFile($query);
  appendSeperator(); 
}

function addAnswer($id,$answer){
  $query = "INSERT INTO answer(id,answer) VALUES ($id,$answer)\n";
  writeToFile($query);
  appendSeperator(); 
}


function writeToFile($text){
	$myFile = "datatext.txt";
	$fh = fopen($myFile, 'a');
	fwrite($fh, $text);
	fclose($fh);
}

function appendSeperator(){
	writeToFile("-----------------------------\n");
}
?>
